// 有效的字母异位词

var isAnagram2 = function (s, t) {
  const map = new Map();
  for (const element of s) {
    map.set(element, (map.get(element) || 0) + 1);
  }
  for (const ele of t) {
    map.set(ele, (map.get(ele) || 0) - 1);
  }
  return [...map.values()].every((item) => item === 0);
};

var isAnagram = function (s, t) {
  if (s.length !== t.length) return false;
  return s.split("").sort().join("") === t.split("").sort().join("");
};

const ans = isAnagram("abccd", "dcbacs");
console.log("ans: ", ans);
